/**
 * 
 */
package com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.usersaction;

import com.alstudio.module.xmpp.protocol.xmpp.packact.ALXmppDomainConfig;
import com.alstudio.module.xmpp.protocol.xmpp.packact.IQNameSpace;
import com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.AlXmlTag;
import com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.BaseIQTemplate;

/**
 * 设置备注名
 * 
 * @author alonso lee
 * 
 */
public class SetNoteNameIQCreator extends BaseIQTemplate {

	private String notename;

	/**
	 * 
	 */
	public SetNoteNameIQCreator(String jid, String notename, String domain) {
		// TODO Auto-generated constructor stub
		this.jid = jid;
		this.domain = domain;
		this.notename = notename;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.alstudio.module.xmpp.protocol.xmpp.util.xmlcreator.iq.BaseIQTemplate
	 * #getIQXml()
	 */
	@Override
	public String getIQXml() {
		// TODO Auto-generated method stub
		String ns = IQNameSpace.NS_ADD_NOTE_NAME;
		AlXmlTag tag = new AlXmlTag("jid");
		tag.setText(jid);
		tagList.add(tag);

		tag = new AlXmlTag("notename");
		tag.setText(notename);
		tagList.add(tag);

		mALIQCreator.setNs(ns);

		mALIQCreator.setType(IQ_TYPE_SET);
		to = ALXmppDomainConfig.getALXmppDomainConfig()
				.getDomainByNameSpace(ns);
		mALIQCreator.setTo(to + domain);

		mALIQCreator.setTagList(tagList);
		String xml = "";
		try {
			xml = mALIQCreator.getXml();
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return xml;
	}

}
